home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00090_Script_Activate-Enable-Disable Buttons
< prev
next >
Wrap
Text File
|
1996-03-28
|
5KB
|
166 lines
-- ---------------------------------------------------------------
-- Handler setTopicButtons sets the casts of the database buttons
-- to the appropriate casts for the clicked topic (0 = disabled,
-- 1 = enabled) and sets the cursor to a finger if enabled.
on setTopicButtons
global clickedTopic, buttonStates, defaultButtonStates
global textButton, pictureButton, textState, pictureState
-- default buttonInfo:
set buttonInfo = clickedTopic & ":" & defaultButtonStates
set the itemDelimiter = ":"
set buttonInfoLine = binSearchFirstItemInLine(buttonStates, clickedTopic, ":")
if (ButtonInfoLine > 0) then
set buttonInfo = line ButtonInfoLine of buttonStates
end if
set textState = value(word 2 of item 2 of buttonInfo)
set pictureState = value(word 2 of item 3 of buttonInfo)
set the itemDelimiter = ","
setButtonState(textState,textButton)
setButtonState(pictureState,pictureButton)
setButtonCursor(textState,textButton)
setButtonCursor(pictureState,pictureButton)
end
-- ---------------------------------------------------------------
-- Handler setButtonState calls the appropriate handler to set the
-- cast of the given button.
on setButtonState buttonState, buttonSprite
if (buttonState) then
enableButton(buttonSprite)
else
disableButton(buttonSprite)
end if
end
-- ---------------------------------------------------------------
-- Handler setButtonCursor sets the cursor of the given buttonSprite
-- to a finger if the button's state is enabled and to the default
-- arrow otherwise.
on setButtonCursor buttonState, buttonSprite
global fingerCursor
if buttonState then
set the cursor of sprite buttonSprite = fingerCursor
else
set the cursor of sprite buttonSprite = -1
end if
end
-- --------------------------------------------------------
-- Handler enableButton makes the given button enabled
-- by changing its cast to its enabled cast.
on enableButton whichSprite
changeButtonCast (whichSprite, "ENABLED")
setButtonCursor (1, whichSprite)
end
-- --------------------------------------------------------
-- Handler disableButton makes the given button disabled
-- by changing its cast to its disabled cast.
on disableButton whichSprite
changeButtonCast (whichSprite, "DISABLED")
setButtonCursor (0, whichSprite)
end
-- --------------------------------------------------------
-- Handler activateButtonKeepActivated makes the given button
-- activated by changing its cast to its activated cast.
on activateButtonKeepActivated whichSprite
changeButtonCast (whichSprite, "ACTIVATED")
setButtonCursor (0, whichSprite)
updateStage
end
-- --------------------------------------------------------
-- Handler activateButtonThenEnable makes the given button activated
-- by changing its cast to its activated cast and then enables the
-- button when the mouse is released.
on activateButtonThenEnable whichSprite
changeButtonCast (whichSprite, "ACTIVATED")
updateStage
repeat while (not the mouseUp)
nothing -- to keep it hilited while the mouse is down
end repeat
changeButtonCast (whichSprite, "ENABLED")
end
-- --------------------------------------------------------
-- Handler changeButtonCast changes the cast of the button
-- in the given sprite according to the given mode.
on changeButtonCast whichSprite, mode
set buttonType = word 1 of the name of cast the castNum of sprite whichSprite
set newCastName = buttonType && mode
set the castNum of sprite whichSprite = the number of cast newCastName
end
-- --------------------------------------------------------
-- Handler isActivated checks if the button in the given sprite
-- is active.
on isActivated whichSprite
if (word 2 of the name of cast the castNum of sprite whichSprite = "ACTIVATED") then
return TRUE
else
return FALSE
end if
end
-- --------------------------------------------------------
-- Handler isEnabled checks if the button in the given sprite
-- is enabled.
on isEnabled whichSprite
if (word 2 of the name of cast the castNum of sprite whichSprite = "ENABLED") then
return TRUE
else
return FALSE
end if
end
-- --------------------------------------------------------
-- Handler isDisabled checks if the button in the given sprite
-- is disabled.
on isDisabled whichSprite
if (word 2 of the name of cast the castNum of sprite whichSprite = "DISABLED") then
return TRUE
else
return FALSE
end if
end
-- --------------------------------------------------------
-- Handler enableTopicButtons
on enableTopicButtons
global pictureButton, textButton
enableButton(pictureButton)
enableButton(textButton)
end
-- --------------------------------------------------------
-- Handler disableTopicButtons
on disableTopicButtons
global textButton, pictureButton
disableButton(textButton)
disableButton(pictureButton)
end